package org.example.util;

import org.example.ITree;
import org.example.RedBlackTree;

public class TreeNodeAdapter implements TreePrintUtil.TreeNode {
    private final ITree.ITreeNode<?, ?> node;
    public TreeNodeAdapter(ITree.ITreeNode<?, ?> node) {
        this.node = node;
    }

    @Override
    public String getPrintInfo() {
        return "[" + node.getKey() + "]";
    }

    @Override
    public TreePrintUtil.TreeNode getLeftChild() {
        return node.getLeft() == null ? null : new TreeNodeAdapter(node.getLeft());
    }

    @Override
    public TreePrintUtil.TreeNode getRightChild() {
        return node.getRight() == null ? null : new TreeNodeAdapter(node.getRight());
    }
}
